package com.fupeng.netease;

import java.util.*;

/**
 * Created by lecky on 2016/8/2 0002.
 */
public class Test {
    public static Queue<Song> getSongs(int time,int k){
        List<Song> lists = getSongsFromDb(time);
        //2,将满足时间条件的歌曲依次放入最大堆中
        Queue<Song> queue = new PriorityQueue(k);
        for(Song song:lists)
            queue.add(song);
        //3，播放次数最多的前K首歌曲
        return queue;
    }

    /*1,从数据库去除满足时间条件的歌曲列表*/
    private static List<Song> getSongsFromDb(int time) {
        return new ArrayList<Song>();
    }
}

class Song implements Comparable{
    private String name;
    private int num;

    @Override
    public int compareTo(Object obj) {
        Song o= (Song) obj;
        if(this.num>o.num)
            return 1;
        else if(this.num<o.num)
            return -1;
        else
            return 0;
    }
}